<!DOCTYPE html>
<html>
<div id="jmsCfg" class="portlet-body form">
  <div class="clear">
    <div class="portlet-title" style="margin-bottom: 10px;">
      <div class="caption font-red">
        <i class="icon-settings font-red" style="margin-left: 20px;"></i> <span
          class="caption-subject bold uppercase">基本配置</span>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">字符集编码</label>
      <div class="col-sm-8">
        <select name="charset" field="charset" required class="form-control select2">
          <option value="UTF-8">UTF-8编码</option>
          <option value="GBK">GBK编码</option>
        </select>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">是否启用</label>
      <div class="col-sm-8">
        <select name="enable" field="enable" required class="form-control select2">
          <option value="true">是</option>
          <option value="false">否</option>
        </select>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">ip</label>
      <div class="col-sm-8">
        <input id="ip_txt" name="ip" field="ip" type="text" class="form-control" required/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">端口号</label>
      <div class="col-sm-8">
        <input id="port_txt" name="port" field="port" type="number" min="1" max="65535" class="form-control" required/>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">队列管理器</label>
      <div class="col-sm-8">
        <input id="qcuName_txt" name="qcuName" field="qcuName" type="text" class="form-control" required/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">消息类型</label>
      <div class="col-sm-8">
        <select name="msgType" field="msgType" class="form-control select2">
          <option value="1">文件</option>
          <option value="0" selected="selected">字符串</option>
        </select>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">文件目录</label>
      <div class="col-sm-8">
        <input id="fileDir_txt" name="fileDir" field="fileDir" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">优先级</label>
      <div class="col-sm-8">
        <input id="priority_txt" name="priority" field="priority" type="text" value="4" class="form-control"/>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">传送方式</label>
      <div class="col-sm-8">
        <select name="encryptOrComp" field="encryptOrComp" class="form-control select2">
          <option value="0" selected="selected">不加密</option>
          <option value="1">只加密</option>
          <option value="2">只压缩</option>
          <option value="3">先加密后压缩</option>
          <option value="4">先压缩后加密</option>
        </select>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">使用事务</label>
      <div class="col-sm-8">
        <select name="transaction" field="transaction" class="form-control select2">
          <option value="1" selected="selected">是</option>
          <option value="0">否</option>
        </select>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">消息最大长度</label>
      <div class="col-sm-8">
        <input id="msgLength_txt" name="msgLength" field="msgLength" value="0" type="digits" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">连接方式</label>
      <div class="col-sm-8">
        <select name="mode" field="mode" class="form-control select2">
          <option value="C" selected="selected">客户端方式</option>
          <option value="S">服务端方式</option>
        </select>
      </div>
    </div>


    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4" id="sendQueueName_title">发送队列</label>
      <div class="col-sm-8">
        <input id="sendQueueName_txt" name="sendQueueName" field="sendQueueName" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">文件发送后删除</label>
      <div class="col-sm-8">
        <select id="comm_type_Select" name="sendFileRemove" field="sendFileRemove" class="form-control select2">
          <option value="0" selected="selected">不删除</option>
          <option value="1">删除</option>
        </select>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">消息周期(秒)</label>
      <div class="col-sm-8">
        <input id="msgTimeout_txt" name="msgTimeout" field="msgTimeout" type="digits" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4" id="receiveQueueName_title">接收队列</label>
      <div class="col-sm-8">
        <input id="receiveQueueName_txt" name="receiveQueueName" field="receiveQueueName" type="text" class="form-control"/>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">接收超时(秒)</label>
      <div class="col-sm-8">
        <input id="receiveTimeout_txt" name="receiveTimeout" field="receiveTimeout" value="30" type="digits" class="form-control"/>
      </div>
    </div>
  </div>


  <div id="threadPool_div" class="clear">
    <div class="portlet-title" style="margin-bottom: 10px;">
      <div class="caption font-red">
        <i class="icon-settings font-red" style="margin-left: 20px;"></i> <span
          class="caption-subject bold uppercase">线程池配置</span>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">最大线程数</label>
      <div class="col-sm-8">
        <input id="maxSize_txt" name="maxSize" field="maxSize" type="number" min="1" required class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">核心线程数</label>
      <div class="col-sm-8">
        <input id="coreSize_txt" name="coreSize" field="coreSize" type="number" min="1" required class="form-control"/>
      </div>
    </div>

    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">缓冲队列大小</label>
      <div class="col-sm-8">
        <input id="capacity_txt" name="capacity" field="capacity" type="number" min="1" required class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">空闲线程存活时间(秒)</label>
      <div class="col-sm-8">
        <input id="aliveTime_txt" name="aliveTime" field="aliveTime" type="number" min="1" required class="form-control"/>
      </div>
    </div>
  </div>

  <div id="out_extcall_div" class="clear">
    <div class="portlet-title" style="margin-bottom: 10px;">
      <div class="caption font-red">
        <i class="icon-settings font-red" style="margin-left: 20px;"></i> <span
          class="caption-subject bold uppercase">配置三方插件</span>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">插件类</label>
      <div class="col-sm-8">
        <input id="exterClass_txt" name="exterClass" field="exterClass" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">报文与通讯函数</label>
      <div class="col-sm-8">
        <input id="externPackAndSend_txt" name="externPackAndSend" field="externPackAndSend" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4 is-required">组包函数</label>
      <div class="col-sm-8">
        <input id="externPack_txt" name="externPack" field="externPack" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">解包函数</label>
      <div class="col-sm-8">
        <input id="externUnpack_txt" name="externUnpack" field="externUnpack" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">通讯函数<span class="required"></span></label>
      <div class="col-sm-8">
        <input id="externSend_txt" name="externSend" field="externSend" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">组包前处理</label>
      <div class="col-sm-8">
        <input id="beforePack_txt" name="beforePack" field="beforePack" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">发送前请求处理</label>
      <div class="col-sm-8">
        <input id="beforeSend_txt" name="beforeSend" field="beforeSend" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">解包前处理</label>
      <div class="col-sm-8">
        <input id="beforeUnpack_txt" name="beforeUnpack" field="beforeUnpack" type="text" class="form-control"/>
      </div>
    </div>
    <div class="form-group col-sm-6">
      <label class="control-label col-sm-4">解包后处理</label>
      <div class="col-sm-8">
        <input id="beforeReturn_txt" name="beforeReturn" field="beforeReturn" type="text" class="form-control"/>
      </div>
    </div>
  </div>
</div>
<script>
  $(function () {
    //根据类型初始化页面元素
    initDom();
    /*var flag = com_action_flag;
    if (flag == "add") {
      var temp_ip = [[${ip}]];
      if (temp_ip != "" && null != temp_ip) {
        swal({
          title: "你加载的配置已经存在，确认需要修改吗？",
          text: "",
          type: "warning",
          showCancelButton: true,
          cancelButtonText: "取消",
          closeOnConfirm: true,
          confirmButtonText: "确定"
        }, function (isConfirm) {
          if (!isConfirm) {
            $("#packet_context_div").empty();
            $("#comm_cfg_form").hide();
          }
        });
      }
    }*/


  });

  //根据类型初始化页面元素
  function initDom() {
    // var type = [[${type}]];
    // if("IN"==type){
    // 	$("#threadPool_div").show();
    // 	$("#id_div").hide();
    // 	$("#out_extcall_div").remove();
    // }else if ("OUT"==type){
    // 	$("#threadPool_div").hide();
    // 	$("#id_div").val("");
    // 	$("#id_div").show();
    // 	$("#out_extcall_div").show();
    // }
    if ($("#commType").val() == "IN") {
      //$("#out_extcall_div").remove();
      //$("#receiveTimeout_txt").parent().parent().remove();
    } else if ($("#commType").val() == "OUT") {
      $("#out_extcall_div").show();
      //接出不展示连接池
      $("#threadPool_div").remove();
    }
    initSendRecv();
  }

  function initSendRecv() {
    var commType = $("#commType").val();
    if ("IN" == commType) {
      //接入时接受队列必填
      $("#receiveQueueName_title").addClass('is-required')
      // $("#receiveQueueName_title").html("接收队列<span class='required'> * </span>");
      // $("#receiveQueueName_txt").rules("add", {required: true, checkInput: true});
      // $("#sendQueueName_txt").rules("remove");
    } else if ("OUT" == commType) {
      //接出时发送队列必填
      $("#sendQueueName_title").addClass('is-required')
      // $("#sendQueueName_title").html("发送队列<span class='required'> * </span>");
      // $("#sendQueueName_txt").rules("add", {required: true, checkInput: true});
      // $("#receiveQueueName_txt").rules("remove");
    }
  }

</script>